<template>
  <el-container class="layout-container">
    <el-header>
      <div class="header-left">
        <h2>问卷调查系统</h2>
      </div>
      <div class="header-right">
        <el-dropdown @command="handleCommand">
          <span class="user-info">
            {{ userInfo.username }}
            <el-icon><ArrowDown /></el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item command="profile">个人信息</el-dropdown-item>
              <el-dropdown-item command="logout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </el-header>
    
    <el-container>
      <el-aside width="200px">
        <el-menu
          router
          :default-active="$route.path"
          class="menu"
        >
          <el-menu-item index="/home">
            <el-icon><House /></el-icon>
            <span>首页</span>
          </el-menu-item>
          
          <el-menu-item index="/questionnaire">
            <el-icon><Document /></el-icon>
            <span>问卷管理</span>
          </el-menu-item>
          
          <el-menu-item index="/announcement">
            <el-icon><Bell /></el-icon>
            <span>公告管理</span>
          </el-menu-item>
          
          <el-menu-item index="/message">
            <el-icon><ChatDotRound /></el-icon>
            <span>留言板</span>
          </el-menu-item>
          
          <el-menu-item index="/forum">
            <el-icon><ChatLineRound /></el-icon>
            <span>论坛</span>
          </el-menu-item>
          
          <el-menu-item index="/news">
            <el-icon><Reading /></el-icon>
            <span>新闻</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { House, Document, Bell, ChatDotRound, ChatLineRound, Reading, ArrowDown } from '@element-plus/icons-vue'

const router = useRouter()
const userInfo = ref({
  username: 'Admin'
})

const handleCommand = (command) => {
  if (command === 'logout') {
    ElMessage.success('退出成功')
    router.push('/login')
  }
}
</script>

<style scoped>
.layout-container {
  height: 100vh;
}
.el-header {
  background-color: #409EFF;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.user-info {
  color: white;
  cursor: pointer;
}
.menu {
  height: 100%;
}
</style> 